//
//  AYSSmallListModel.m
//  AiYingShiProject
//
//  Created by lanou on 15/11/2.
//  Copyright (c) 2015年 李晓理. All rights reserved.
//

#import "AYSSmallListModel.h"

@implementation AYSSmallListModel
- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    //命名规范原因重设description和id赋值方式
    if ([key isEqualToString:@"description"])
    {
        self.videoListDescription = value;
    }
    if ([key isEqualToString:@"id"])
    {
        self.videoListID = value;
    }
}

+ (AYSSmallListModel *)shareJsonWithDic1:(NSDictionary *)dic1 dic2:(NSDictionary *)dic2 dic3:(NSDictionary *)dic3 dic4:(NSDictionary *)dic4 arr:(NSArray *)array
{
    AYSSmallListModel *model = [[AYSSmallListModel alloc] init];
    [model setValuesForKeysWithDictionary:dic1];
    [model setValuesForKeysWithDictionary:dic2];
    [model setValuesForKeysWithDictionary:dic3];
    [model setValuesForKeysWithDictionary:dic4];
    //视频网址 高清/普通
    if (array.count == 2)
    {
        model.normalUrl = array[0][@"url"];
        model.highUrl = array[1][@"url"];
    }
    else
    {
        model.normalUrl = array[0][@"url"];
    }
    return model;
}

+ (AYSSmallListModel *)shareJsonWithDic2:(NSDictionary *)dic2 dic3:(NSDictionary *)dic3 dic4:(NSDictionary *)dic4 arr:(NSArray *)array
{
    AYSSmallListModel *model = [[AYSSmallListModel alloc] init];
    [model setValuesForKeysWithDictionary:dic2];
    [model setValuesForKeysWithDictionary:dic3];
    [model setValuesForKeysWithDictionary:dic4];
    //视频网址 高清/普通
    if (array.count == 2)
    {
        model.normalUrl = array[0][@"url"];
        model.highUrl = array[1][@"url"];
    }
    else
    {
        model.normalUrl = array[0][@"url"];
    }
    return model;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.nextPageUrl forKey:@"nextPageUrl"];
    [aCoder encodeObject:self.nextPublishTime forKey:@"nextPublishTime"];
    [aCoder encodeObject:self.date forKey:@"date"];
    [aCoder encodeObject:self.total forKey:@"total"];
    [aCoder encodeObject:self.category forKey:@"category"];
    [aCoder encodeObject:self.coverBlurred forKey:@"coverBlurred"];
    [aCoder encodeObject:self.coverForDetail forKey:@"coverForDetail"];
    [aCoder encodeObject:self.coverForFeed forKey:@"coverForFeed"];
    [aCoder encodeObject:self.coverForSharing forKey:@"coverForSharing"];
    [aCoder encodeObject:self.videoListDescription forKey:@"description"];
    [aCoder encodeObject:self.duration forKey:@"duration"];
    [aCoder encodeObject:self.videoListID forKey:@"id"];
    [aCoder encodeObject:self.idx forKey:@"idx"];
    [aCoder encodeObject:self.title forKey:@"title"];
    [aCoder encodeObject:self.normalUrl forKey:@"normalUrl"];
    [aCoder encodeObject:self.highUrl forKey:@"highUrl"];
    [aCoder encodeObject:self.icon forKey:@"icon"];
    [aCoder encodeObject:self.name forKey:@"name"];
    
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self)
    {
        self.nextPageUrl = [aDecoder decodeObjectForKey:@"nextPageUrl"];
        self.nextPublishTime = [aDecoder decodeObjectForKey:@"nextPublishTime"];
        self.date = [aDecoder decodeObjectForKey:@"date"];
        self.total = [aDecoder decodeObjectForKey:@"total"];
        self.category = [aDecoder decodeObjectForKey:@"category"];
        self.coverBlurred = [aDecoder decodeObjectForKey:@"coverBlurred"];
        self.coverForDetail = [aDecoder decodeObjectForKey:@"coverForDetail"];
        self.coverForFeed = [aDecoder decodeObjectForKey:@"coverForFeed"];
        self.coverForSharing = [aDecoder decodeObjectForKey:@"coverForSharing"];
        self.videoListDescription = [aDecoder decodeObjectForKey:@"description"];
        self.duration = [aDecoder decodeObjectForKey:@"duration"];
        self.nextPublishTime = [aDecoder decodeObjectForKey:@"nextPublishTime"];
        self.videoListID = [aDecoder decodeObjectForKey:@"id"];
        self.idx = [aDecoder decodeObjectForKey:@"idx"];
        self.title = [aDecoder decodeObjectForKey:@"title"];
        self.normalUrl = [aDecoder decodeObjectForKey:@"normalUrl"];
        self.highUrl = [aDecoder decodeObjectForKey:@"highUrl"];
        self.icon = [aDecoder decodeObjectForKey:@"icon"];
        self.name = [aDecoder decodeObjectForKey:@"name"];
    }
    return self;
}


@end
